<div class="HDR_results">
    <div class="resultsHeader">
        <h3><a href="http://televisadeportes.esmas.com/" target="_blank">Resultados al minuto</a></h3>
        <a id="next-arrow" href="#">next</a>
        <a id="prev-arrow" href="#">prev</a>
        <ul id="results">
	        <li class="h-event vevent" id="hcalendar-brazil-vs-japan">
		        <time datetime="2013-07-10T14:00-05:00" class="dtstart">10/07/2013 14:00</time> <time datetime="2013-06-10T16:00-05:00" class="screenreader dtend">16:00</time>
                <span class="screenreader">
	                : <span class="summary">brasil vs. japón</span> at <span class="location">stadium</span>
		            <span class="description">copa oro opening game</span>
	            </span>
                <span class="screenreader">
	                <span class="category">soccer</span>
	                <span class="category">football</span>
	                <span class="category">futbol</span>
	                <span class="category">fut</span>
	                <span class="category">televisa</span>
	                <span class="category">deportes</span>
	                <span class="category">copa oro</span>
	                <span class="category">concacaf</span>
                </span>
            </li>
        </ul>
	</div>
</div>
<script type="text/javascript" src="http://www.esmas.com/scripts/esmas_stats.js"></script>
<script type="text/javascript">
        var valor=1;
        var refreshtimeesp=1;
        var refreshtimeespoff=30;
        var refresp=7;
        var recarga = 0;
        var otrocar = null
        var carmenu = null;
        var jsonres;
        var jsonres2;
        var tElementC = 0;
        var unixTimeNow = 0;
        var ramVAL = 0;
                
        function SefcountSeven() {
            var pix = new Image();
            pix.src = doStats('return');
        }

        var iframeSEFITV=setInterval('SefcountSeven()',refresp*60000);

        var structureTicker = new Class({
            urlActivoTorneo :  null ,
            posActivoTorneo :  null ,
            loadCarousel    : 0,
            timeser         : 0,
            dateser         : 0,
            totalMatch        : 0,
            country :        'MX',
            timeNow         :0,
            banderaRefresh  :0,
            Implements: Options,
            options: {
                typeTemplete : 1
            },
            initialize: function(options) {
                this.setOptions(options);
            },
            datetime : function() {
                datosHoraFec =new  Request.JSON({
                    method : 'get',
                    url: 'http://mxm.televisadeportes.esmas.com/deportes/home/timetv.js',
                    onComplete: function(data) {
                        this.timeser = data.timetv;
                        this.dateser = data.fechatv;
                        vhr = this.timeser.split(':');
                        ramVAL = vhr[0]+vhr[1];
                        obj1.tournaments();
                    }
                }).get();
            },
            tournaments : function() {
                $('hiddenMenu2').innerHTML='';
                var currentTime = new Date();
                var hours = currentTime.getHours();
                var minutes = currentTime.getMinutes();
                urljsonTicker = 'http://mxm.televisadeportes.esmas.com/deportes/home/Ticker_14.js';
                var obj = this;
                dataTicker = new Request.JSON({
                    method : 'get',
                    url:urljsonTicker,
                    data: 'v=' + ramVAL,
                    onComplete:function(data){
                        jsonres = data.ticker.widgets;
                        obj.printTournament();
                    }
                }).get();
            },
            printTournament: function (){
                this.totalItems = jsonres.widgets.length;
                for (var i=0; i<this.totalItems; i++) {
                    this.nameTournament = jsonres.widgets[i].title;
                    this.jsonWidget = jsonres.widgets[i].urldata;
                    if (jsonres.widgets[i].activo === 1 && this.urlActivoTorneo === null){
                        this.urlActivoTorneo = jsonres.widgets[i].urldata;
                        this.posActivoTorneo = i;
                    }
                    this.contador = i;
                    this.cellTournaments();
                }
                this.insMenuTournaments();
            },
            cellTournaments :function (){
                var obj =this;
                var Cont =this.contador;
                var Name =this.nameTournament;
                var UrlWidget =this.jsonWidget;
                var    itemNew = new Element('li',{
                    id: 'item'+Cont
                });
                $('hiddenMenu2').grab(itemNew);
                var itemNew2 = new Element('span', {
                    html:Name,
                    events: {
                        click: function(){
                            obj.widgetActivo(Cont,UrlWidget);
                        }
                    }
                });
                $('item'+Cont).grab(itemNew2);
            },
            insMenuTournaments : function (){
                var obj =this;
                carmenu = new CarruselF('TDCarouselHeader2','hiddenMenu2', {
                    nextElementID: 'next-arrowmenu',
                    prevElementID: 'prev-arrowmenu',
                    curnextElementSrc: 'http://i2.esmas.com/deportes30/img/carrusel/confederaciones-2013/widget_mxm_fl-Ac-der.gif',
                    curprevElementSrc: 'http://i2.esmas.com/deportes30/img/carrusel/confederaciones-2013/widget_mxm_fl-Ac-izq.gif',
                    altnextElementSrc: 'http://i2.esmas.com/deportes30/img/carrusel/confederaciones-2013/widget_mxm_fl-In-der.gif',
                    altprevElementSrc: 'http://i2.esmas.com/deportes30/img/carrusel/confederaciones-2013/widget_mxm_fl-In-izq.gif',
                    scrollInc: 4,
                    numVisible: 5,
                    size: obj.totalItems,
                    reset:true
                });
                $$('#hiddenMenu2').setStyle('left', '0px');
                this.widgetActivo(this.posActivoTorneo , this.urlActivoTorneo);
            },
            widgetActivo: function(pos, urlw) {
                this.urlActivoTorneo    =urlw;
                this.posActivoTorneo = pos;
                $$('#hiddenMenu2 li').removeClass('menuiActive');
                $('item'+pos).addClass('menuiActive');
                this.wigetFutbol(urlw);
            },
            wigetFutbol: function(fjson, param) {
                var str = fjson.replace('jsonp.js', '.js');
                str = str.replace('http://interacciontd.televisadeportes.esmas.com/deportes/home/', 'http://mxm.televisadeportes.esmas.com/deportes/home/');
                str = str.replace('http://interacciontd.televisadeportes.esmas.com/deportes/home/', 'http://mxm.televisadeportes.esmas.com/deportes/home/');

                $('TDWidgetHeader1').innerHTML='';
                var currentTime = new Date();
                var hours = currentTime.getHours();
                var minutes = currentTime.getMinutes();
                var obj = this;
                dataTicker =new  Request.JSON({
                    method : 'get',
                    url:str ,
                    data: 'v='+ramVAL,
                    onComplete:function(data){
                        jsonres2 = data.matches.match;
                        unixTimeNow = data.matches.timeNow;
                        obj.matches();
                    }
                }).get();
            },
            matches: function() {
                this.timeNow =parseInt(unixTimeNow)
                var tiempoEspera = 30;
                var segunosEspera  =  parseInt (30* 60);
                timeAfter =parseInt (this.timeNow  + segunosEspera );
                this.totalMatch  = jsonres2.length;
                this.cont2=0;
                this.banderaRefresh = 0;
                for (var j=0 ; j<this.totalMatch; j++){
                    var horaFecPartido = parseInt(jsonres2[j].TimeStamp);
                    if (((horaFecPartido+300) >= this.timeNow &&  (horaFecPartido -300) <= timeAfter ) || (jsonres2[j].period != 'F' && jsonres2[j].period != 'P' && jsonres2[j].period != '' )) {
                        this.banderaRefresh = 1;
                    }
                    if(jsonres2[j].period == 'P' || jsonres2[j].period== 'F'){
                        this.variable_clase = 'IcGame';
                    } else {
                        this.variable_clase = 'AcGame';
                    }
        
                    tipoWidget ='Futtol' ;
        
                    this.MatchHour2     =    jsonres2[j].MatchHour2;
                    this.periodabrev    =    jsonres2[j].periodabrev;
                    this.MatchDate      =    jsonres2[j].MatchDate;
                    this.torneo         =     jsonres2[j].EventTournamentId;
                    this.txtLink        =     jsonres2[j].txtLink ;
                    this.period         =     jsonres2[j].period;
                    this.torneoNom      =     jsonres2[j].EventTournamentName;
                    this.Website        =     jsonres2[j].Website;
                    this.MXvideo        =     jsonres2[j].MXvideo;
                    this.USAvideo       =     jsonres2[j].USAvideo;
                    // DATOS DEL LOCAL
                    this.lpenals        =     jsonres2[j].equipos.local.penals;
                    this.lname          =     jsonres2[j].equipos.local.name;
                    this.lclub          =     jsonres2[j].equipos.local.name;
                    this.lgoals         =     jsonres2[j].equipos.local.goals;
                    this.lresult        =     jsonres2[j].equipos.local.result;
                    this.vpenals        =     jsonres2[j].equipos.visit.penals;
                    this.vname          =     jsonres2[j].equipos.visit.name;
                    this.vclub          =     jsonres2[j].equipos.visit.name;
                    this.vgoals         =     jsonres2[j].equipos.visit.goals;
                    this.vresult        =     jsonres2[j].equipos.visit.result;
                    this.cellWidgetFutbol();
                    this.cont2 ++;
                }
                this.instMenuWidgets(this.totalMatch);
            },
            cellWidgetFutbol:function() {
                var obj = this;
                var txtsts ='';
                var imgVideo= '';
                var penalL ='';
                var penalV ='';
                if ( (this.period=='PT' ) || ( (this.period=='F') && ( this.vpenals > 0 || this.lpenals > 0 ) ) ){
                    penalL= '('+this.lpenals+')' ;
                    penalV= '('+this.vpenals+')' ;
                }
                var itemNew = new Element('li', {
                    id: 'item2_'+obj.cont2,
                    'class' : obj.variable_clase
                });
                $('TDWidgetHeader1').grab(itemNew);
                var itemNew2 = new Element('ul', { id : 'contItem'+obj.cont2, 'class' : 'containerWid' });
                $('item2_'+obj.cont2).grab(itemNew2);
                var itemNew3 = new Element('li', {
                    'class' : 'nameTournament',
                    'onclick':"window.open('"+((obj.Website!='')?obj.Website:'http://televisadeportes.esmas.com/')+"', '_blank'); return false;",
                    'style':'cursor:pointer;',
                        html:'<span class=\'nomTorneo\'>'+obj.torneoNom+'</span>'
                    });
                    
                var itemNew4 = new Element('li', {
                    'class' : 'dataMatch',
                    'onclick':"window.open('"+((obj.Website!='')?obj.Website:'http://televisadeportes.esmas.com/')+"', '_blank'); return false;",
                    'style':'cursor:pointer;',
                    html:'<span>'+obj.MatchDate+'</span><span class="schedule">'+obj.MatchHour2+' hrs.</span><span class="periodos">'+obj.periodabrev+'</span>'
                });
                
                var itemNew5 = new Element('li', {
                    'class' : 'nameItem',
                    'onclick':"window.open('"+((obj.Website!='')?obj.Website:'http://televisadeportes.esmas.com/')+"', '_blank'); return false;",
                    'style':'cursor:pointer;',
                    html:'<span class="nomEqui">'+obj.lclub+'</span><span class="penalti">'+penalL+'</span><span class="numberSpan1">'+obj.lgoals+'</span>'
                });
                
                var itemNew6 = new Element('li', {
                    'class' : 'nameItem',
                    'onclick':"window.open('"+((obj.Website!='')?obj.Website:'http://televisadeportes.esmas.com/')+"', '_blank'); return false;",
                    'style':'cursor:pointer;',
                    html:'<span  class="nomEqui">'+obj.vclub+'</span><span class="penalti">'+penalV+'</span><span class="numberSpan1">'+obj.vgoals+'</span>'
                });
                if (this.Website !='') {
                    txtsts = this.txtLink;
                }
                var videoMex  = this.MXvideo;
                var partVideo = videoMex.split('@@@');
                var videoUsa = this.USAvideo;
                var partVideo2 = videoUsa.split('@@@');
            
                if (this.country=='MX') {
                    if (partVideo[0]!='') {
                        imgVideo = '<img src="http://i2.esmas.com/deportes30/img/carrusel/confederaciones-2013/video_widget_icon.gif">' + partVideo[1];
                    }
                } else {
                    if (partVideo2[0] != '') {
                        imgVideo = '<img src="http://i2.esmas.com/deportes30/img/carrusel/confederaciones-2013/video_widget_icon.gif">' + partVideo2[1];
                    }
                }
                var itemNew7 = new Element('li', {
                    'class' : 'matchSttus',
                    html:'<span class="minuteLink footerl"><a class="textoMs" style="text-decoration:underline" target="_blank" href="'+obj.Website+'"> '+txtsts+'</a></span><span class="rightAlignVd"> <a class="txtRojo" target="_blank" href ="'+partVideo[0]+'">'+imgVideo+' </a></span>'
                });
                $('contItem'+obj.cont2).grab(itemNew3);
                $('contItem'+obj.cont2).grab(itemNew4);
                $('contItem'+obj.cont2).grab(itemNew5);
                $('contItem'+obj.cont2).grab(itemNew6);
                $('contItem'+obj.cont2).grab(itemNew7);
        },
    instMenuWidgets: function(Matches, reseteando) {
        var reseteando = true;
        otrocar = new CarruselF('TDCarouselHeader1','TDWidgetHeader1', {
            nextElementID:'next-arrow',
            prevElementID:'prev-arrow',
            scrollInc:4,
            numVisible:5,
            size:Matches,
            reset:reseteando
        });

        if(reseteando) {
            $('TDWidgetHeader1').style.left='0px';
            otrocar.currentIndex = 0;
            $('prev-arrow').style.display='none';
            if (Matches < 5) {
                $('next-arrow').addClass('esconde');
            } else {
                $('next-arrow').removeClass('esconde');
            }
        }

        $$('.IcGame').each(function(itm){
            itm.addEvents({
                mouseover: function(){
                    this.toggleClass('inactiveGame');
                },
                mouseout: function(){
                    this.toggleClass('inactiveGame');
                }
            });
        });
        $$('.AcGame').each(function(itm){
            itm.addEvents({
                mouseover: function(){
                    this.toggleClass('activeGame');
                },
                mouseout: function(){
                    this.toggleClass('activeGame');
                }
            });
        });
        this.refreshFlag ();
    },
    boxShow : function (param){
        if (param==1) {
            var visibles =  otrocar.currentIndex+8;
        } else {
            var visibles =  otrocar.currentIndex;
        }

        if (visibles>=this.totalMatch) {
            $('next-arrow').addClass('esconde');
        } else {
            $('next-arrow').removeClass('esconde');
        }
    },
    refreshFlag : function (){
        clearInterval (recarga);
        var obj = this;
        if (this.banderaRefresh==0){
            recarga = setInterval (function (){  obj.widgetActivo(obj.posActivoTorneo , obj.urlActivoTorneo) }, refreshtimeespoff*60000 );
        } else if (this.banderaRefresh==1) {
            recarga = setInterval (function (){  obj.widgetActivo(obj.posActivoTorneo , obj.urlActivoTorneo) }, refreshtimeesp*60000 );
        }
    }
});
        
obj1 = new structureTicker({
    typeTemplete : 2
});

obj1.datetime();

$('next-arrow').addEvent('click', function(){
    obj1.boxShow(1);
});

$('prev-arrow').addEvent('click', function(){
    obj1.boxShow(2);
});

setInterval( function(){ramVAL = addMinuteToTime(ramVAL, refreshtimeesp);}, 60000);

function addMinuteToTime(horaComp, addMin) {
    "use strict";
    var hour, min;
    hour = horaComp.substr(0, 2);
    min = horaComp.substr(2, 2);
    if (min === (60 - addMin)) {
        hour = hour + 1;
        if (hour === "24") {
            hour = "00";
        }
        min = (addMin - 1);
        if (min < 10) {
            min = '0' + min;
        }
    } else {
        min = eval(min) + addMin;
        if (min > 60) {
            min = min - 60;
            hour = hour + 1;
            if (hour > 23) {
                hour = hour - 24;
            }
        }
        if (min < 10) {
            min = '0' + eval(min);
        }
        if (hour < 10) {
            hour = '0' + eval(hour);
        }
    }
    return hour.toString() + min.toString();
}
</script>
<script type="text/javascript">doStats('esmas');</script>
<script type="text/javascript">document.write('<script type=\'text/javascript\' src=\'http://ad.doubleclick.net/adj/'+Site+'/'+Zona+';zone0='+Zona+';id='+ ( ( typeof id_note != 'undefined' ) ? id_note : '' ) + ';id2=' + ( ( typeof id_especial2 != 'undefined' ) ? id_especial2 : '' ) + ';id3=' + ( ( typeof zone != 'undefined' ) ? zone : '' ) + ';id4=' + ( ( typeof subzone != 'undefined' ) ? subzone : '' ) + ';id5=' + ( ( typeof lt_index != 'undefined' ) ? lt_index : '' ) + ';tile='+Tile+';sz='+Size+';ord='+ ( ( typeof esmas_dart_ord != 'undefined' ) ? esmas_dart_ord : '' ) + '?\'><'+'/'+'script>');</script>
